<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let xuexiao = {
            school: 'b站',
            students: [
                'pink',
                'SkyBlue',
                'block',
                'red'

            ],
            // 迭代器自定义遍历数据
            [Symbol.iterator]() {
                let index = 0
                return {
                    next: () => {
                        if (index < this.students.length) {
                            const res = { value: this.students[index], done: false }
                            index++
                            return res
                        } else {
                            return { value: undefined, done: true }
                        }

                    }

                }
            }
        }
        for (let s of xuexiao) {
            console.log(s);
        }

    </script>
</body>

</html>